﻿// ---------------------------------------------------------------------------------------------------------------------
//   Copyright (c) SRT Solutions 2009. All rights reserved.
// ---------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using SRTSolutions.Elevate;

namespace SRTSolutions.Elevate.Guide._001_Sequences._001_CreatingSequences
{
    public class _001_UsingExistingValues
    {
        [Test]
        public void BuildingASequenceFromValues()
        {
            //if you want to create an IEnumerable out of a few elements, you could do it like this
            var standardDotNet = new string[] { "alpha", "beta", "gamma", "delta" };

            //with Elevate, you can do this much more easily
            IEnumerable<string> withElevate = Seq.Build("alpha", "beta", "gamma", "delta");

            Assert.AreEqual(standardDotNet, withElevate);
        }

        [Test]
        public void AddingValuesToASequence()
        {
            //if you have a sequence of values
            var sequence = Seq.Build("alpha", "beta", "gamma", "delta");

            //you can add a few values on to the end using the same tactic as above
            var result = Seq.Build(sequence, "epsilon", "zeta");

            var expected = Seq.Build("alpha", "beta", "gamma", "delta", "epsilon", "zeta");
            Assert.AreEqual(expected, result);
        }

        [Test]
        public void MixingAndMatching()
        {
            //if you have a couple sequences of values
            var first = Seq.Build("alpha", "beta");
            var second = Seq.Build("delta", "epsilon");

            //you can combine them along with some other values to create a new sequence
            var result = Seq.Build(first, "gamma", second, "zeta");

            var expected = Seq.Build("alpha", "beta", "gamma", "delta", "epsilon", "zeta");
            Assert.AreEqual(expected, result);
        }
        
        //NOTE: There are limitations to the number of overloads that we can generate for doing
        //      this type of sequence construction due to performance reasons with Visual Studio.
    }
}
